﻿using System;
using System.Data;
using System.Data.SqlClient;

public class AdminChangePswrdDAL
    {
       public   int ChangePassword(AdminChangePaswrdBO ChangePassword)
       {
           dbConnection db = new dbConnection();
           SqlConnection cn = null;
           SqlCommand cmd = null;
           int Counter = 0;

           try
           {
               cn = new SqlConnection();
               cn.ConnectionString = db.GetCS();

               cmd = new SqlCommand();
               cmd.Connection = cn;
               cmd.CommandType = CommandType.Text;
               cmd.CommandText = "UPDATE [Admin] SET  [Password]=@Password WHERE UserName=@UserName";

               cmd.Parameters.AddWithValue("@UserName", ChangePassword.UserName);
               cmd.Parameters.AddWithValue("@Password", ChangePassword.Password);

               cn.Open();
               Counter = cmd.ExecuteNonQuery();

           }
           catch (Exception ex)
           {
               throw new Exception(ex.Message);
           }
           finally
           {
               if (cn != null)
               {
                   cn.Close();
                   cn.Dispose();
                   cn = null;
               }
           }
           return (Counter);
       }
    }

